package com.cy.thread;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author : 残影
 * @Date: 2021-03-24 10:15
 */
public class CASDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);
        System.out.println(atomicInteger.compareAndSet(5, 2021)+"\t current data: "+atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5, 1024)+"\t current data: "+atomicInteger.get());
        atomicInteger.getAndIncrement();
    }
}
